#ifndef __BLINK_H__
#define __BLINK_H__

#include "plat/nonecopyable.h"
#include "soc/soc_gpio.h"
#include "os/timer.h"

class Blink : public NoneCopyable
{
public:
   Blink();
   Blink(GpioPort port, int pin, int normalLevel,
         int ontime, int offtime, int repeat = -1);
   virtual ~Blink();

public:
   void SetInfo(GpioPort port, int pin, int normalLevel,
                int ontime, int offtime, int repeat = -1);

   void Start();
   void Stop();
   
private:
   void ToggleImpl();

private:
   GpioPort m_port;
   uint8_t m_pin;
   uint8_t m_normalLevel = 0;
   int m_ontime = 0;
   int m_offtime = 0;
   int m_repeats = 0;

   uint8_t m_currentVal = 0;
   Timer m_timer;
};

#endif // __BLINK_H__